# No arguments - generate link output to one portal or all portals, 
# depending on the number of portals the user has access to.

# vim: syntax=perl:ts=4:sw=4
use gri_secmgr qw(get_cookie_value);

sub mm_show_one_or_all_portals {

	# Get the username from the cookie

	my $v=get_cookie_value(name=>"gri_dbm_intranet");
	$v =~ s/\s+.*//;
	my $lref=$::GRI_FRONTEND->get_portal_list();
	my @L=(@$lref);

	# We simply show the list of portals in a mini-table.

	my $count=0;
	my $p1;
	for my $c (@L) {
		my $a=$::GRI_FRONTEND->is_user_allowed($c,$v);
		if($a) {
			if($count==0) {
				$p1=$c;
			}
			$count++ if $a;
		}
	}
	my $l="";
	if($count==1) {
		my $pp=string_to_hex($p1);
		$l=link_to_str("stdlink","$p1","portal_tl","portal=$pp");
	} elsif($count>1) {
		$l=link_to_str("stdlink","Portal List","","");
	}
	return $l;
}

